package com.ss.android.messagebus.a;

import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;

import com.ss.android.messagebus.e;

public class AsyncMessageHandler implements c {
    c a;
    private MessageBusHandlerThread mMessageBusHandlerThread;

    public AsyncMessageHandler() {
        this.a = new d();
        this.mMessageBusHandlerThread = new MessageBusHandlerThread(AsyncMessageHandler.class.getSimpleName());
        this.mMessageBusHandlerThread.start();
    }

    public final void a(final e arg4, final Object arg5) {
        MessageBusHandlerThread messageBusHandlerThread = this.mMessageBusHandlerThread;
        Runnable runnable = new Runnable() {

            public final void run() {
                AsyncMessageHandler.this.a.a(arg4, arg5);
            }
        };
        if (messageBusHandlerThread.mAsyncHandler == null) {
            Log.d("AsyncMessageHandler", "mAsyncHandler == null, please call start() first.");
        } else {
            messageBusHandlerThread.mAsyncHandler.post(((Runnable) runnable));
        }
    }

    final class MessageBusHandlerThread extends HandlerThread {
        Handler mAsyncHandler;

        public MessageBusHandlerThread(String name) {
            super(name);
        }

        public synchronized final void start() {
            super.start();
            this.mAsyncHandler = new Handler(this.getLooper());
        }
    }
}

